#!/usr/bin/env node

const http = require('http'),
      fs = require('fs');

const data = require('./data.js');

let movieData = data.filter(item=>item.movieRange!=='暂无评分');

movieData.sort((a,b)=>{
  return -(a.movieRange-b.movieRange);
})


http.createServer((req,res)=>{
  let file = fs.readFileSync('index.html');

  if(req.url==='/'){
    res.end(file);
  }

  if(req.url==='/getlist'){
    res.end(JSON.stringify(movieData));
  }
}).listen(8080); 
